{extend name="base" /}
{block name="body"}
<div class="layui-card">
	<div class="layui-card-body">
		<form action="{:url('admin/projectrecommend/index')}" class="layui-form" method="get">
			<div class="layui-form-item">
				<div class="layui-inline">
					项目名称
				</div>
				<div class="layui-inline">
					<input type="text" name="name" value="{:input('name')}" autocomplete="off" placeholder="项目名称" class="layui-input"/>
				</div>
				<div class="layui-inline">
					创建时间
				</div>
				<div class="layui-inline">
					<input type="text" id="createFrom" name="createFrom" value="{:input('createFrom')}" autocomplete="off" class="layui-input"/>
				</div>
				<div class="layui-inline">
					到
				</div>
				<div class="layui-inline">
					<input type="text" id="createTo" name="createTo" value="{:input('createTo')}" autocomplete="off" class="layui-input"/>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layui-btn-normal ajax-search"><i class="fa fa-search"></i></button>
				</div>
			</div>
		</form>
        <div class="layui-btn-group">
		    <a onclick="add()" class="layui-btn"><i class="fa fa-plus-circle"></i> 添加项目</a>
        </div>
		<table class="layui-table layui-form">
			<thead>
			<tr>
				<th>项目名称</th>
				<th>项目关键词</th>
				<th>项目需求</th>
				<th>项目来源</th>
				<th>金额</th>
				<th>年限</th>
				<th>操作</th>
				<th>选择专家</th>
			</tr>
			</thead>
			<tbody>
			{foreach name="list" item="v" empty="$empty"}
			<tr>
				<td>{$v.name}</td>
				<td>{$v.keyword}</td>
				<td>
					{if !empty($v['demand'])}
						<a onclick="showDemand('{$v.demand}')" class="layui-btn layui-btn-xs layui-btn-normal">点击查看</a>
					{/if}
				</td>
				<td>{$v.source}</td>
				<td>{$v.amount}</td>
				<td>{$v.year}</td>
				<td>
					<a onclick="edit({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 编辑</a>
					<a href="{:url('admin/projectrecommend/del', ['id' => $v.id])}" class="layui-btn layui-btn-xs layui-btn-danger ajax-delete"><i class="fa fa-trash-o"></i> 删除</a>
				</td>
				<td>
					<a onclick="choose({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 选择专家</a>
					{if !empty($v['notice_people'])}
						<a onclick="findPeople({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 查看专家</a>
					{/if}
				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
	</div>
</div>
{/block}
{block name="js"}
<script>
	//iframe 层
	function showDemand(data) {
		if (data === '' || data === null || data === undefined) {
			layer.msg("该学者暂无履历");
			return
		}
		//自定页
		layer.open({
			type: 1,
			title: '项目需求',
			closeBtn: 0, //不显示关闭按钮
			anim: 2,
			skin: 'layui-layer-demo',
			shadeClose: true, //开启遮罩关闭
			area: ['480px', '320px'],
			content: data
		});
	}

	function add() {
		layer.open({
			type: 2,
			title: '添加项目推荐',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/projectrecommend/add',
		});
	}

	function edit(data) {
		layer.open({
			type: 2,
			title: '修改项目推荐',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/projectrecommend/edit?id=' + data,
		});
	}

	function choose(data) {
		layer.open({
			type: 2,
			title: '选择专家',
			shadeClose: true,
			shade: false,
			area: ['90%', '90%'],
			content: '/admin/projectrecommend/userIndex?projectRecommendId=' + data,
		});
	}

	function findPeople(data) {
		layer.open({
			type: 2,
			title: '查看已选择专家',
			shadeClose: true,
			shade: false,
			area: ['90%', '90%'],
			content: '/admin/projectrecommend/choosePeople?projectRecommendId=' + data,
		});
	}

	laydate.render({
		elem: '#createFrom',
		type: 'date'
	})
	laydate.render({
		elem: '#createTo',
		type: 'date'
	})
</script>
{/block}